package janino;

import org.codehaus.commons.compiler.CompileException;
import org.codehaus.janino.*;

import java.lang.reflect.InvocationTargetException;

public class JaninoDemo {

    public static void main(String[] args) throws InvocationTargetException, CompileException {
        ExpressionEvaluator ee = new ExpressionEvaluator();
        ee.setParameters(new String[]{"param"}, new Class[]{Param.class});
        ee.setExpressionType(String.class);
        ee.cook("param.getA() + param.getB()");
        Param param = new Param();
        param.setA("a");
        param.setB("B");
        String resultStr = (String) ee.evaluate(new Param[]{param});
        System.out.println(resultStr);
    }
}